package milkyway.hightech.b2b;

import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;


public class BankRegistry
{
    private static BankRegistry registry;

    Map<String, B2B> map = new HashMap<String, B2B>();

    private BankRegistry()
    {
	
    }
    
    public static BankRegistry getInstance()
    {
	if(registry == null)
	    registry = new BankRegistry();

	return registry;
    }


    public void bind(String name, B2B bank)
    {
	map.put(name, bank);
    }

    public B2B lookup(String name)
    {
	if(map.containsKey(name))
	    return map.get(name);
	else 
	    throw new NoSuchElementException("Bank not found");
    }
}